home *** CD-ROM | disk | FTP | other *** search
- Path: dispatch.news.demon.net!demon!harlquin.demon.co.uk
- From: vaughan@harlquin.demon.co.uk (vaughan edwards)
- Newsgroups: comp.lang.c++
- Subject: STL and sort
- Date: Wed, 06 Mar 1996 16:35:31 GMT
- Message-ID: <826130135.20401@harlquin.demon.co.uk>
- NNTP-Posting-Host: harlquin.demon.co.uk
- X-NNTP-Posting-Host: harlquin.demon.co.uk
- X-Newsreader: Forte Agent .99c/32.126
-
- Being new to STL, I am working through some of the examples in the
- documentation.
-
- Using GCC, all was fine until I attempted to sort a vector using the
- following code:
-
- //------------------
-
- //misc code
-
-
- struct NameCompare {
- bool operator()(const person& a, const person &b)
- {return a.last_name < b.last_name;}
- }
-
- NameCompare nameComp;
-
- vector<person> roster;
-
- // add persons
-
- sort(roster.begin(), roster.end(),nameComp);
-
- // etc
-
- //----------------
-
- this results in the following compiler errors
-
- /usr/include/g++/algo.h: In function `void __quick_sort_loop(struct
- person *, struct person *, struct NameCompare)':
- /usr/include/g++/algo.h:746: call of overloaded `value_type' is
- ambiguous
- /usr/include/g++/vector.h:180: candidates are: value_type(person
- *const &)
- /usr/include/g++/iterator.h:90: value_type(const
- person *)
- /usr/include/g++/algo.h: In function `void
- __unguarded_insertion_sort(struct person *, struct person *, struct
- NameCompare)':
- /usr/include/g++/algo.h:834: call of overloaded `value_type' is
- ambiguous
- /usr/include/g++/vector.h:180: candidates are: value_type(person
- *const &)
- /usr/include/g++/iterator.h:90: value_type(const
- person *)
- /usr/include/g++/algo.h: In function `void __insertion_sort(struct
- person *, struct person *, struct NameCompare)':
- /usr/include/g++/algo.h:806: call of overloaded `value_type' is
- ambiguous
- /usr/include/g++/vector.h:180: candidates are: value_type(person
- *const &)
- /usr/include/g++/iterator.h:90: value_type(const
- person *)
-
-
- probably something simple - but I could do with some pointers
-
-
- TIA
-
- Vaughan
-
-
-
-